/*
    文件内容: Timestamp,事件类
    文件名: Timestamp.cpp
    作者: 中国好青年(码农论坛)
    时间: 2024/10/18
*/
#include "TimeStamp.h"
/* 构造函数 和 析构函数 */
TimeStamp::TimeStamp()
{
    secsinceepoch_ = time(0);
}

TimeStamp TimeStamp::now()
{
    return TimeStamp();
}

time_t TimeStamp::to_int() const
{
    return secsinceepoch_;
}

std::string TimeStamp::tostring()
{
    char buff[128] = {0};
    tm *tm_time=localtime(&secsinceepoch_);
    snprintf(buff, 128, "%4d-%02d-%02d %02d:%02d:%02d", tm_time->tm_year+1900, tm_time->tm_mon+1, tm_time->tm_mday
                                                      , tm_time->tm_hour, tm_time-> tm_min, tm_time->tm_sec);
    return buff;
}

TimeStamp::~TimeStamp()
{

}